home *** CD-ROM | disk | FTP | other *** search
- /*
- * (c) Copyright 1993, 1994, 1995, 1996 Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
- * any purpose and without fee is hereby granted, provided that the above
- * copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
- * the name of Silicon Graphics, Inc. not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission.
- *
- * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
- * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
- * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
- * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
- * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
- * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
- * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
- * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
- * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
- * Use, duplication, or disclosure by the Government is subject to
- * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
- * (c)(1)(ii) of the Rights in Technical Data and Computer Software
- * clause at DFARS 252.227-7013 and/or in similar or successor
- * clauses in the FAR or the DOD or NASA FAR Supplement.
- * Unpublished-- rights reserved under the copyright laws of the
- * United States. Contractor/manufacturer is Silicon Graphics,
- * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
- *
- * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
- */
- #include "gl.h"
- #include "glu.h"
- #include "agl.h"
- #include "tk.h"
- #include "aux.h"
-
- #include <math.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- #include <time.h>
-
- #if defined(__MWERKS__) || defined(__SC__)
- #include <console.h> /* ccommand */
- #endif
-
- #include "scene.h"
-
- void Draw(void);
- void Reshape(int w, int h);
- float rand_s(float min, float max) ;
-
- static float dtheta[nlights];
- static int texture_available = 0;
-
- float rand_s(float min, float max)
- {
- double r;
- r = (double)rand() / (double)RAND_MAX;
- return min + r * (max - min);
- }
-
- void Draw(void)
- {
- int i;
-
- for (i = 0; i < nlights; i++)
- dtheta[i] = rand_s(-90, 90);
-
- for (i = 0; i < nlights; i++)
- scene_move(name_lights + i, 0, 0, dtheta[i] * 0.01, 1);
-
- scene_draw();
-
- auxSwapBuffers();
- }
-
- void Reshape(int w, int h)
- {
- glViewport(0, 0, w, h);
- aspect = (GLfloat) w / (GLfloat) h;
- }
-
- static GLenum KeyDown(int key, GLenum mask)
- {
- switch (key)
- {
- case TK_1:
- draw_texture = (texture_available ? !draw_texture : draw_texture);
- break;
- case TK_2:
- draw_square = !draw_square;
- break;
- case TK_3:
- draw_shadows = !draw_shadows;
- break;
- case TK_4:
- draw_refraction = !draw_refraction;
- break;
- case TK_5:
- draw_sphere = !draw_sphere;
- break;
- case TK_6:
- draw_lights = !draw_lights;
- break;
- default:
- return GL_FALSE;
- }
-
- return GL_TRUE;
- }
-
- void main(int argc, char **argv)
- {
- #if defined(__MWERKS__) || defined(__SC__)
- argc = ccommand(&argv);
- #endif
-
- if(argc > 1) scene_load_texture(argv[1]);
-
- auxInitDisplayMode (AUX_DOUBLE | AUX_RGB | AUX_DEPTH | AUX_STENCIL);
- auxInitPosition (30, 60, 400, 400);
- auxInitWindow ("Backtrace");
-
- srand(clock());
-
- scene_init();
-
- texture_available = (argc > 1);
- draw_texture = texture_available;
- draw_square = 1;
- draw_shadows = 1;
- draw_refraction = 1;
- draw_sphere = 1;
- draw_lights = 1;
-
- /*glDisable(GL_DITHER);*/
-
- auxReshapeFunc(Reshape);
- auxExposeFunc(Reshape);
- tkKeyDownFunc(KeyDown);
- auxIdleFunc(Draw);
- auxMainLoop(Draw);
- }
-